{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用 openai 调用MiniCPM-2B-sft-bf16\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os \n",
    "\n",
    "os.environ['OPENAI_API_BASE'] = 'http://127.0.0.1:8080/v1'\n",
    "os.environ['OPENAI_API_KEY'] = ''\n",
    "\n",
    "model_path = '/Users/a/.cache/huggingface/hub/models--openbmb--MiniCPM-2B-sft-bf16/snapshots/fe1d74027ebdd81cef5f815fa3a2d432a6b5de2a/pytorch_model.bin'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain import OpenAI, LLMChain, PromptTemplate\n",
    "from langchain.memory import ConversationBufferWindowMemory\n",
    "from langchain.embeddings import OpenAIEmbeddings\n",
    " "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import openai \n",
    "def get_completion(prompt,model='gpt-3.5-turbo'):\n",
    "    msg = [\n",
    "        {'role':'user','content':prompt}\n",
    "    ]\n",
    "    res = openai.ChatCompletion.create(\n",
    "        model_path =model_path,\n",
    "        \n",
    "    )\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
